import wxRequest from '@/utils/wxRequest'
import { get1stHostName } from '@/utils'

export function getPaymentParamsAPI(type, openid, out_trade_no) {
  // 不同公众号的domain不同
  const hostname = get1stHostName()

  return wxRequest({
    url: '/api/payment/',
    method: 'post',
    data: {
      type,
      openid,
      out_trade_no,
      hostname
    }
  })
}

export function rechargeAPI ({ openid, amount }) {
  return wxRequest({
    url: '/api/cash-recharge/',
    method: 'post',
    data: {
      openid,
      amount
    }
  })
}
